﻿using System;
using System.Collections.Generic;
using System.Data;
using Module.Core.DAO;
using Module.Core.EntitiesInfo;
using Module.Common.Models;

namespace Module.Core.BusinessLogic
{
    public class ChuyenGoldBL
	{
		/// <summary>
		/// Saves a record to the ChuyenGold table.
		/// </summary>
		public static int Insert(ChuyenGoldInfo chuyenGoldInfo)
		{
			try
			{
				return new ChuyenGoldDAO().Insert(chuyenGoldInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Saves a record to the ChuyenGold table.
		/// </summary>
        public static void Update(ChuyenGoldInfo chuyenGoldInfo)
		{
			try
			{
				new ChuyenGoldDAO().Update(chuyenGoldInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Delete a record from the ChuyenGold table.
		/// </summary>
        public static void Delete(int id)
		{
			try
			{
				new ChuyenGoldDAO().Delete(id);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Selects a single record from the ChuyenGold table.
		/// </summary>
        public static ChuyenGoldInfo Select(int id)
		{
			try
			{
				return new ChuyenGoldDAO().Select(id);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Selects all records from the ChuyenGold table.
		/// </summary>
        public static CHRTList<ChuyenGoldInfo> SelectAll()
		{
			try
			{
				return new ChuyenGoldDAO().SelectAll();
			}
			catch (Exception ex)
			{
				throw;
			}

		}
       

        public static int GetCount(int Id, DateTime createOnFrom, DateTime createOnTo)
        {
            try
            {
                return new ChuyenGoldDAO().GetCount(Id, createOnFrom, createOnTo);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public static DataSet ListChuyenGoldPage(int Id, DateTime createOnFrom, DateTime createOnTo, int currPage, int recodperPage, int pageSize, int total)
        {
            try
            {
                DataSet ds = new DataSet();

                ds = new ChuyenGoldDAO().ListChuyenGoldPage(Id,createOnFrom, createOnTo, currPage, recodperPage, pageSize, total);
                if (ds != null)
                    return ds;
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        #region Danh sach chuyen gold qua tài khoản ví Dealcom + ATM

        public static int SelectCount(int status,int type, string CodeMember_To, string CodeMember_Form, string startdate, string enddate)
        {
            try
            {
                return new ChuyenGoldDAO().SelectCount(status,type, CodeMember_To, CodeMember_Form, startdate, enddate);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static DataTable Search(int status,int type,string CodeMember_To, string CodeMember_Form, string starDatetime, string endDatetime, int beginRow, int endRow, string orderByColumn, bool isTotalRow)
        {
            try
            {
                return new ChuyenGoldDAO().Search(status,type,CodeMember_To, CodeMember_Form, starDatetime, endDatetime, beginRow, endRow, orderByColumn, isTotalRow);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        #endregion

      

        //Update lại trạng thái Status=2 -Chuyển gold ATM đang chờ xác nhận
        //Status=1 -Chuyển gold qua ATM đã xác nhận
        public static void UpdateStatus(int id, int status)
        {
            try
            {
                new ChuyenGoldDAO().UpdateStatus(id, status);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

	}
}
